M2.5 Contracts Upgrade Plan
Motivation
With M2.5 (https://github.com/FilOzone/filecoin-services/issues/147) landing soon, we need to prepare FilCDN for upgrading as quickly as possible, so that the CDN integration still works with the current to-be-used FOC contracts.
Changed components
⚠️
All contracts will be upgraded without migrating their previous state, so all old FilCDN deals need to be expired
FilecoinWarmStorageService
- https://github.com/FilOzone/filecoin-services/commit/e24ce373a2259183c24f10dd89b55726f03b53a3#diff-15b517a541a03e881ca66c72cde2412a763a9c32420819ba9574c3dd8ec4361d
- Event
ProofSetRailCreated- Rename to
DataSetRailCreated
- Rename argument
proofSetIdtodataSetId
- Rename to
- Event
- https://github.com/FilOzone/filecoin-services/commit/a27fea644c8a75de6d777f059962b97b2fbe8307
- Event
DataSetRailCreated- Rename to
DataSetRailsCreated
- Add additional arguments (not relevant)
- Rename to
- Event
- https://github.com/FilOzone/filecoin-services/commit/c524249c391d301201a5ccaf21edc0e056a072b0
- Rename contract to
FilecoinWarmStorageService
- Rename contract to
- https://github.com/FilOzone/filecoin-services/commit/19d5dcc52c18fed0b5015a1f70539b278d56fea4
- Remove event
ProviderRegistered
- Remove event
ProviderApproved
- Remove event
PDPVerifier
- https://github.com/FilOzone/pdp/commit/5d59f00a35ff9b6fe32a31e01bd475ec5d8178be#diff-5450b4dd41c13d3dc0a8dbf7e8e085a30beccf6355092792c315e3444da344d0
- Event
ProofSetCreated- Rename to
DataSetCreated
- Rename argument
ownertostorageProvider
- Rename to
- Event
RootsAdded- Rename to
PiecesAdded
- Rename argument
rootIdstopieceIds
- Rename to
- Event
RootsRemoved- Rename to
PiecesRemoved
- Rename argument
rootIdstopieceIds
- Rename to
- Function
getRootCid- Rename to
getPieceCid
- Rename argument
rootIdtopieceId
- Rename to
- Event
- Add
PieceCIDstoPiecesAddedevent https://github.com/FilOzone/pdp/pull/169- Event
PiecesAdded- Argument
pieceCids
- Argument
- Event
Open PRs
Pull requests that are expected to land for M2.5.
⚠️
These might still change before landing
FilecoinWarmStorageService
- Beneficiary separation https://github.com/FilOzone/filecoin-services/pull/111
- Event
DataSetRailsCreated- Rename argument
payeetocontroller
- Rename argument
- Event
- Implement Key-Value Metadata Structure https://github.com/FilOzone/filecoin-services/pull/131
- Event
DataSetRailsCreated- Rename to
DataSetCreated
- Remove argument
withCDN
- Add arguments
metaDataKeys,metaDataValues
- Rename to
- Event
ServiceRegistry
- A new Service Registry Contract for Filecoin Synapse https://github.com/FilOzone/filecoin-services/pull/142
- Contract
ServiceProviderRegistry
- Event
ProviderRegistered- Argument
providerId(new provider ID)
- Argument
owner(replaces previousproviderargument)
- Argument
- Event
ProviderRemoved- Argument
providerId
- Argument
- Event
ProductRemoved- Argument
providerId
- Argument
productType
- Argument
- Method
getPDPProduct(providerId)- Includes previous
serviceURLin return value
- Should be called after event
ProductUpdatedorProductAdded
- Includes previous
- Contract
Components to change
⚠️
In addition to all changes outlined, we need a mainnet deployment in addition to the existing calibration deployment. Let’s do this once the contracts are live.
Goldsky
Subgraphs
- Deploy
FilecoinWarmStorageServicesubgraph from repo- Wait for available
- Deploy
PDPVerifiersubgraph from repo- Wait for available
- Deploy
ServiceProviderRegistrysubgraph from repo- Wait for available
Pipelines
-
FilecoinWarmStorageService- Wait for subgraph to be deployed
- Forward event
DataSetCreatedto/filecoin-warm-storage-service/data-set-created
-
PDPVerifier- Wait for subgraph to be deployed
- Forward event
DataSetCreatedto/pdp-verifier/data-set-created
- Forward event
PiecesAddedto/pdp-verifier/pieces-added
- Forward event
PiecesRemovedto/pdp-verifier/pieces-removed
-
ServiceProviderRegistry- Wait for subgraph to be deployed
- Forward event
ProviderRegisteredto/service-provider-registry/provider-registered
- Forward event
ProviderRemovedto/service-provider-registry/provider-removed
- Forward event
ServiceUpdatedto/service-provider-registry/service-updated
- Forward event
ProductAddedto/service-provider-registry/product-added
- Forward event
ProductRemovedto/service-provider-registry/product-removed
D1 Tables (PR #1)
https://github.com/filcdn/worker/pull/224
- Switch to new databases
- And if necessary flush old rows
-
provider_urls- Rename
piece_retrieval_urltoservice_url
- Allow
service_urlto be NULL
- Add
provider_idcolumn
- Move primary key from
addresstoprovider_id
- Rename
addresstoowner
- Rename
-
indexer_proof_set_rails- Rename table to
data_sets
- Rename column
proof_set_idtodata_set_id
- Rename column
payeetocontroller(for #111)
- Rename table to
-
indexer_proof_sets- Merge with
data_sets(based on keyset_id)
- Merge with
-
indexer_roots- Rename table to
pieces
- Rename column
root_idtopiece_id
- Rename column
set_idtodata_set_id
- Rename column
root_cidtopiece_cid
- Rename table to
-
proof_set_stats- Rename table to
data_set_stats
- Rename column
set_idtodata_set_id
- Rename table to
-
retrieval_logs- Rename column
proof_set_idtodata_set_id
- Rename column
Workers (PR #1 @Julian Gruber)
https://github.com/filcdn/worker/pull/224
Indexer
- Update smart contract addresses
- Event
PDPVerifier.ProofSetCreated- Rename endpoint to
/pdp-verifier/data-set-created
- Schema updates
- Rename endpoint to
- Event
PDPVerifier.RootsAdded- Rename endpoint to
/pdp-verifier/roots-added
- Call
PDPVerifier.getPieceCid()
- Schema updates
- Rename endpoint to
- Event
PDPVerifier.RootsRemoved- Rename endpoint to
/pdp-verifier/pieces-removed
- Schema updates
- Rename endpoint to
- Event
Pandora.ProofSetRailCreated- Rename endpoint to
/filecoin-warm-storage-service/data-set-created
- Get
data_set_idnotproof_set_idfrom event
- Persist
data_set_idnotproof_set_id
- Table now called
data_sets
- Read
withCDNfrom new metadata fields
- Other schema updates
- Rename endpoint to
- Event
Pandora.ProviderRegistered- Rename endpoint to
/service-provider-registry/provider-registered
- Remove writing of
serviceURL, will only be known later
- Instead of
address, writeprovider_idandowner
- Other schema updates
- Rename endpoint to
- Event
Pandora.ProviderRemoved- Rename endpoint to
/service-provider-registry/provider-removed
- Change query to select based on
provider_idnotaddress
- Other schema updates
- Rename endpoint to
- Events
ServiceProviderRegistry.ServiceUpdatedandServiceProviderRegistry.ProductAdded- Create new endpoint that listens to
/service-provider-registry/service-updatedand/service-provider-registry/product-added
- Call
ServiceProviderRegistry.getPDPService()to getserviceURL
- Persist new or updated
serviceURLinprovider_urls.service_url
- Other schema updates
- Create new endpoint that listens to
Retriever
- Update smart contract addresses
- Adjust to new D1 schema
- Read
provider_urls.service_urlinstead ofprovider_urls.piece_retrieval_url- Update URL construction based on read value
- Handle
service_url = NULL
- Other schema updates
- Read
Bot (PR #2 @Srdjan Stankovic)
- Contract ABI update
- Schema updates
Main work items
- Goldsky
- Main PR: Database & Workers updates for components already changed
https://github.com/filcdn/worker/pull/224
- Bot PR
- Tracking PRs for components still in progress (these should be worked on after the main PR is ready)
- Beneficiary separation PR
- Key-value metadata PR
- Mainnet deployment
Code sequence
What to work on in what order:
graph TD;
Goldsky
main[Main PR]
bot[Bot PR]
subgraph Tracking
Beneficiary
kv[Key-value metadata]
end
ct[(Contract deployment)]
main --> Tracking
ct --> Goldsky
Deployment sequence
What can be merged/shipped in what order:
graph TD;
Goldsky
main[Main PR]
bot[Bot PR]
subgraph Tracking
Beneficiary
kv[Key-value metadata]
end
ct[(Contract deployment)]
ct --> Goldsky
ct --> Tracking
Goldsky --> main
Tracking --> main
main --> bot
bot --> m[Mainnet deployment of everything, the above is calibration]
Branching strategy:
- Create M2.5 PR
- Create main PR targeting M2.5 PR
- Can be split into multiple PRs if possible
- Once the main PR is merged to M2.5 PR
- Create tracking PRs also targeting M2.5 PR
- Merge M2.5 PR into main
- This step will execute the database migrations
Rename databases:
filcdn-mainnet-db
filcdn-calibration-db